﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ZuesControls.Helpers;

namespace ZuesControls.Controls
{
    public class ZSTreeViewItem:TreeViewItem
    {
        private TextBox textbox;

        static ZSTreeViewItem()
        {

            DefaultStyleKeyProperty.OverrideMetadata(typeof(ZSTreeViewItem), new FrameworkPropertyMetadata(typeof(ZSTreeViewItem)));
          
        }


        public ZSTreeViewItem()
        {
            this.Loaded += ZSTreeViewItem_Loaded;
        }
        public static readonly DependencyProperty TreeLevelProperty =
      DependencyProperty.Register(
          nameof(TreeLevel),
          typeof(int),
          typeof(ZSTreeView),
          new FrameworkPropertyMetadata(2, FrameworkPropertyMetadataOptions.Inherits));

        public ZSTreeViewItem ParentTreeViewItem { get { return ItemsControl.ItemsControlFromItemContainer(this) as ZSTreeViewItem; } }

        public new bool IsVisible
        {
            get
            {
                if (Visibility != Visibility.Visible) return false;
                ZSTreeViewItem currentItem = ParentTreeViewItem;
                while (currentItem != null)
                {
                    if (!currentItem.IsExpanded) return false;
                    currentItem = currentItem.ParentTreeViewItem;
                }

                return true;
            }
        }

        public int TreeLevel
        {
            get => (int)GetValue(TreeLevelProperty);
            set => SetValue(TreeLevelProperty, value);
        }
        private void ZSTreeViewItem_Loaded(object sender, RoutedEventArgs e)
        {
           

            
        }
    }
}
